<?php
$br = "<br/>\n";


echo '匹配汉字一' . $br;
$str = "我是个男子汉";
$pattern = '/[\x{4e00}-\x{9fa5}]/u';   //包含匹配
//$pattern = '/^[\x{4e00}-\x{9fa5}]+$/u';  
$bool = preg_match($pattern, $str, $match);
var_dump($bool,$match);

echo '匹配汉字二' . $br;
$pattern = '/\p{Han}/u';
$bool = preg_match($pattern, $str, $match);
var_dump($bool,$match);


echo "<br/>\分隔座机好</br>";
$str = '4008259527';
$pattern = '/(\d{3})/i';
$replacement = '${1}-';
var_dump(preg_replace($pattern, $replacement, $str, 2));

echo "<br/>\识别零个</br>";
$str = '';
$rs = preg_match_all('/.*/', $str, $match);
var_dump($rs, $match);



echo '匹配标签' . $br;
$pattern = '/<\/?\b[^>]+>/';
$str = '<div class="no"><p>this is class</p></div>';
$bool = preg_match($pattern, $str, $match);

echo  "匹配DIV标签" . $br;
$str = '<div class="video-title">哈哈哈哈哈哈</div>';
preg_match_all('/<div.*?>(.*?)<\/div>/i',$str,$arr);
var_dump($arr);

//正则匹配url地址 https://
$url = 'https:/\www.baidu.com';
$res = preg_match('/^http[s]?:\/\//', $url, $match);
var_dump($res,$match);